import tinymce from 'tinymce/tinymce'
/**
 * 编辑器的附录名字输入变化时触发该事件
 * @param {*} editor
 */
export default function (editor) {
  editor.on('updateFormulaNumber', () => {
    const nodes = editor.getDoc()?.querySelectorAll(`[data-type="formula"]:not(.term-block [data-type="formula"])`)
    nodes.forEach((node, idx) => {
      editor.dom.setAttrib(node, 'data-formula-number', idx + 1)
      editor.dom.setAttrib(node.querySelector('.img-wrapper'), 'data-formula-number', idx + 1)
    })
  })
}
